package com.yphone.ui.pay.model;

import com.google.gson.reflect.TypeToken;
import com.yphone.net.HttpConstants;
import com.yphone.net.IUIDataListener;
import com.yphone.net.bean.BaseResultWrapper;
import com.yphone.net.helper.ActivityHttpHelper;
import com.yphone.ui.login.bean.request.BaseHttpRequest;
import com.yphone.ui.login.manager.LoginManager;
import com.yphone.ui.pay.bean.PayInfo;
import com.yphone.ui.pay.contract.PayActivityContract;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class PayViewModel implements PayActivityContract.Imodel {
    private ActivityHttpHelper<BaseResultWrapper<List<PayInfo>>> httpHelper;

    @Override
    public void request(IUIDataListener iuiDataListener) {
        try {
            if (this.httpHelper == null) {
                this.httpHelper = new ActivityHttpHelper<>(new TypeToken<BaseResultWrapper<List<PayInfo>>>() {
                });
            }
//            ExtendServicesRequest info = new ExtendServicesRequest();
            BaseHttpRequest baseHttpRequest = new BaseHttpRequest();
            this.httpHelper.UpdateUIDataListener(iuiDataListener);
            BaseResultWrapper<List<PayInfo>> listBaseResultWrapper = new BaseResultWrapper<>();
//            listBaseResultWrapper.data = getTestData();
            iuiDataListener.uiDataSuccess(listBaseResultWrapper);
            HashMap<String, String> map = new HashMap<>();
            map.put("token", LoginManager.getInstance().getToken());
            this.httpHelper.sendPostRequest(HttpConstants.get_pay_service, map, HttpConstants.TIME_OUT3);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public ArrayList<PayInfo> getTestData(){
        ArrayList<PayInfo> payInfos = new ArrayList<>();
        PayInfo payInfo = new PayInfo(1,"VIP月卡",50,80,"畅玩30天");
        PayInfo payInfo1 = new PayInfo(2,"VIP季卡",140,150,"畅玩90天");
        PayInfo payInfo2 = new PayInfo(3,"VIP半年卡",260,300,"畅玩半年");
        PayInfo payInfo3 = new PayInfo(4,"VIP年卡",500,600,"畅玩一年");
        payInfos.add(payInfo);
        payInfos.add(payInfo1);
        payInfos.add(payInfo2);
        payInfos.add(payInfo3);
        return payInfos;
    }


}
